<pre>
# ord()将字符转换为ASCII码


def count(s):
    count_letter = count_number = 0
    for i in s:
        if (ord(i) >= 97 and ord(i) <= 122) or (ord(i) >= 65 and ord(i) <= 90):
            count_letter = count_letter+1
        elif(ord(i) >= 48 and ord(i) <= 57):
            count_number = count_number+1

    print("%d个字母,%d个数字" % (count_letter, count_number))


if __name__ == "__main__":
    s = input("请输入一串字符：")
    count(s)
</pre>